/**
 * @Author：ming
 * @Date：2023/9/27 1:12 AM
 * @Filename：Lc69
 */

import java.util.logging.Level;

/**
 * @author ming
 */
public class Lc69 {
    public int mySqrt(int x) {
        double low = 0;
        double high = x;

        int index = 0;
        double mid = (low+x)/2;
        while ((x-mid*mid)>0.001){
           if(mid*mid<x){
               low = mid;
               mid = (mid+ high)/2;

           }else if(mid*mid>x) {
               high =mid;
               mid = (mid+low)/2;
           }else {
               index =(int) mid;
           }
        }

        index =(int) mid;

        return index;
    }
}
